|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the "Elastic License |
| 4 | + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side |
| 5 | + * Public License v 1"; you may not use this file except in compliance with, at |
| 6 | + * your election, the "Elastic License 2.0", the "GNU Affero General Public |
| 7 | + * License v3.0 only", or the "Server Side Public License, v 1". |
| 8 | + */ |
| 9 | + |
| 10 | +import { Fields } from '../../entity'; |
| 11 | +import { Serializable } from '../../serializable'; |
| 12 | +import { OtelEdotMetric } from './metric'; |
| 13 | +import { OtelEdotTransaction } from './transaction'; |
| 14 | + |
| 15 | +interface OtelEdotSharedResourceAttributes { |
| 16 | + 'service.name'?: string; |
| 17 | + 'agent.name'?: string; |
| 18 | + 'agent.version'?: string; |
| 19 | + 'metricset.interval'?: string; |
| 20 | + 'service.instance.id'?: string; |
| 21 | + 'telemetry.sdk.language'?: string; |
| 22 | + 'telemetry.sdk.name'?: string; |
| 23 | + 'telemetry.sdk.version'?: string; |
| 24 | +} |
| 25 | + |
| 26 | +export interface OtelEdotDocument extends Fields { |
| 27 | + data_stream?: { |
| 28 | + dataset: string; |
| 29 | + namespace: string; |
| 30 | + type: string; |
| 31 | + }; |
| 32 | + attributes?: { |
| 33 | + 'timestamp.us'?: number; |
| 34 | + 'metricset.name'?: string; |
| 35 | + [key: string]: any; |
| 36 | + }; |
| 37 | + resource?: { |
| 38 | + attributes?: OtelEdotSharedResourceAttributes; |
| 39 | + dropped_attributes_count?: number; |
| 40 | + schema_url?: string; |
| 41 | + }; |
| 42 | + scope?: { |
| 43 | + attributes?: { |
| 44 | + 'service.framework.name'?: string; |
| 45 | + 'service.framework.version'?: string; |
| 46 | + }; |
| 47 | + dropped_attributes_count?: number; |
| 48 | + name?: string; |
| 49 | + }; |
| 50 | + name?: string; |
| 51 | + trace_id?: string; |
| 52 | + trace?: { id: string }; |
| 53 | + span_id?: string; |
| 54 | + span?: { id: string }; |
| 55 | + dropped_attributes_count?: number; |
| 56 | + dropped_events_count?: number; |
| 57 | + dropped_links_count?: number; |
| 58 | + timestamp_us?: number; |
| 59 | +} |
| 60 | + |
| 61 | +class OtelEdot extends Serializable<OtelEdotDocument> { |
| 62 | + constructor(fields: OtelEdotDocument) { |
| 63 | + super({ |
| 64 | + ...fields, |
| 65 | + }); |
| 66 | + } |
| 67 | + |
| 68 | + metric() { |
| 69 | + return new OtelEdotMetric({ |
| 70 | + ...this.fields, |
| 71 | + attributes: { |
| 72 | + 'service.name': 'adservice-edot-synth', |
| 73 | + 'span.kind': 'SPAN_KIND_INTERNAL', |
| 74 | + 'span.name': 'SynchronizationContext#drain', |
| 75 | + 'status.code': 'STATUS_CODE_UNSET', |
| 76 | + 'metricset.name': 'service_summary', |
| 77 | + 'processor.event': 'metric', |
| 78 | + }, |
| 79 | + data_stream: { |
| 80 | + dataset: 'generic.otel', |
| 81 | + namespace: 'default', |
| 82 | + type: 'metrics', |
| 83 | + }, |
| 84 | + metrics: { |
| 85 | + 'traces.span.metrics.calls': 1, |
| 86 | + }, |
| 87 | + resource: { |
| 88 | + attributes: { |
| 89 | + 'agent.name': 'opentelemetry/java/elastic', |
| 90 | + 'agent.version': '1.0.1-SNAPSHOT', |
| 91 | + 'app.label.name': 'otel-demo-blue-adservice-edot-synth', |
| 92 | + 'cloud.account.id': 'elastic-product', |
| 93 | + 'cloud.availability_zone': 'us-central1-a', |
| 94 | + 'cloud.platform': 'gcp_kubernetes_engine', |
| 95 | + 'cloud.provider': 'gcp', |
| 96 | + 'container.id': 'e4f5dd426472aacd6124e85a0cd8a1ef55c263374c16179d1bf75292224c2dc0', |
| 97 | + 'deployment.environment': 'opentelemetry-demo', |
| 98 | + 'host.arch': 'amd64', |
| 99 | + 'host.id': '8645892066193866279', |
| 100 | + 'host.name': 'gke-demo-elastic-co-pool-5-29a9d3db-t79s', |
| 101 | + 'k8s.cluster.name': 'demo-elastic-co', |
| 102 | + 'k8s.deployment.name': 'otel-demo-blue-adservice-edot-synth', |
| 103 | + 'k8s.namespace.name': 'otel-blue', |
| 104 | + 'k8s.node.name': 'gke-demo-elastic-co-pool-5-29a9d3db-t79s', |
| 105 | + 'k8s.pod.ip': '10.12.3.63', |
| 106 | + 'k8s.pod.name': 'otel-demo-blue-adservice-edot-synth-7c68c8f968-tvf54', |
| 107 | + 'k8s.pod.start_time': '2025-01-15T12:51:39Z', |
| 108 | + 'k8s.pod.uid': 'da7a8507-53be-421c-8d77-984f12397213', |
| 109 | + 'k8s.replicaset.name': 'otel-demo-blue-adservice-edot-synth-7c68c8f968', |
| 110 | + 'os.description': 'Linux 5.15.109+', |
| 111 | + 'os.type': 'linux', |
| 112 | + 'process.command_line': |
| 113 | + '/opt/java/openjdk/bin/java -javaagent:/usr/src/app/opentelemetry-javaagent.jar oteldemo.AdServiceEdotSynth', |
| 114 | + 'process.executable.path': '/opt/java/openjdk/bin/java', |
| 115 | + 'process.pid': 1, |
| 116 | + 'process.runtime.description': 'Eclipse Adoptium OpenJDK 64-Bit Server VM 21.0.5+11-LTS', |
| 117 | + 'process.runtime.name': 'OpenJDK Runtime Environment', |
| 118 | + 'process.runtime.version': '21.0.5+11-LTS', |
| 119 | + 'service.instance.id': 'da7a8507-53be-421c-8d77-984f12397213', |
| 120 | + 'service.name': 'adservice-edot-synth', |
| 121 | + 'service.namespace': 'opentelemetry-demo', |
| 122 | + 'telemetry.distro.name': 'elastic', |
| 123 | + 'telemetry.distro.version': '1.0.1-SNAPSHOT', |
| 124 | + 'telemetry.sdk.language': 'java', |
| 125 | + 'telemetry.sdk.name': 'opentelemetry', |
| 126 | + 'telemetry.sdk.version': '1.43.0', |
| 127 | + }, |
| 128 | + }, |
| 129 | + scope: { |
| 130 | + dropped_attributes_count: 0, |
| 131 | + name: 'spanmetricsconnector', |
| 132 | + }, |
| 133 | + }); |
| 134 | + } |
| 135 | + |
| 136 | + transaction(id: string) { |
| 137 | + return new OtelEdotTransaction({ |
| 138 | + ...this.fields, |
| 139 | + attributes: { |
| 140 | + 'app.ads.ad_request_type': 'TARGETED', |
| 141 | + 'app.ads.ad_response_type': 'TARGETED', |
| 142 | + 'app.ads.contextKeys': '[travel]', |
| 143 | + 'app.ads.contextKeys.count': 1, |
| 144 | + 'app.ads.count': 1, |
| 145 | + 'event.outcome': 'success', |
| 146 | + 'event.success_count': 1, |
| 147 | + 'network.peer.address': '10.12.9.56', |
| 148 | + 'network.peer.port': 41208, |
| 149 | + 'network.type': 'ipv4', |
| 150 | + 'processor.event': 'transaction', |
| 151 | + 'rpc.grpc.status_code': 0, |
| 152 | + 'rpc.method': 'GetAds', |
| 153 | + 'rpc.service': 'oteldemo.AdServiceEdotSynth', |
| 154 | + 'rpc.system': 'grpc', |
| 155 | + 'server.address': 'otel-demo-blue-adservice-edot-synth', |
| 156 | + 'server.port': 8080, |
| 157 | + 'session.id': 'ce3ed7c7-47d7-42a5-baae-86d0a716752d', |
| 158 | + 'thread.id': 9412, |
| 159 | + 'thread.name': 'grpc-default-executor-23', |
| 160 | + 'timestamp.us': 1740679709260508, |
| 161 | + 'transaction.duration.us': 551, |
| 162 | + 'transaction.id': id, |
| 163 | + 'transaction.name': 'oteldemo.AdServiceEdotSynth/GetAds', |
| 164 | + 'transaction.representative_count': 1, |
| 165 | + 'transaction.result': 'OK', |
| 166 | + 'transaction.root': false, |
| 167 | + 'transaction.sampled': true, |
| 168 | + 'transaction.type': 'request', |
| 169 | + }, |
| 170 | + data_stream: { |
| 171 | + dataset: 'generic.otel', |
| 172 | + namespace: 'default', |
| 173 | + type: 'traces', |
| 174 | + }, |
| 175 | + duration: 551551, |
| 176 | + kind: 'Server', |
| 177 | + name: 'oteldemo.AdServiceEdotSynth/GetAds', |
| 178 | + // parent_span_id: 'b8fc0a55e4ae6b53', |
| 179 | + resource: { |
| 180 | + attributes: { |
| 181 | + 'agent.name': 'opentelemetry/java/elastic', |
| 182 | + 'agent.version': '1.0.1-SNAPSHOT', |
| 183 | + 'app.label.name': 'otel-demo-blue-adservice-edot-synth', |
| 184 | + 'cloud.account.id': 'elastic-product', |
| 185 | + 'cloud.availability_zone': 'us-central1-a', |
| 186 | + 'cloud.platform': 'gcp_kubernetes_engine', |
| 187 | + 'cloud.provider': 'gcp', |
| 188 | + 'container.id': 'e4f5dd426472aacd6124e85a0cd8a1ef55c263374c16179d1bf75292224c2dc0', |
| 189 | + 'deployment.environment': 'opentelemetry-demo', |
| 190 | + 'host.arch': 'amd64', |
| 191 | + 'host.id': '8645892066193866279', |
| 192 | + 'host.name': 'gke-demo-elastic-co-pool-5-29a9d3db-t79s', |
| 193 | + 'k8s.cluster.name': 'demo-elastic-co', |
| 194 | + 'k8s.deployment.name': 'otel-demo-blue-adservice-edot-synth', |
| 195 | + 'k8s.namespace.name': 'otel-blue', |
| 196 | + 'k8s.node.name': 'gke-demo-elastic-co-pool-5-29a9d3db-t79s', |
| 197 | + 'k8s.pod.ip': '10.12.3.63', |
| 198 | + 'k8s.pod.name': 'otel-demo-blue-adservice-edot-synth-7c68c8f968-tvf54', |
| 199 | + 'k8s.pod.start_time': '2025-01-15T12:51:39Z', |
| 200 | + 'k8s.pod.uid': 'da7a8507-53be-421c-8d77-984f12397213', |
| 201 | + 'k8s.replicaset.name': 'otel-demo-blue-adservice-edot-synth-7c68c8f968', |
| 202 | + 'os.description': 'Linux 5.15.109+', |
| 203 | + 'os.type': 'linux', |
| 204 | + 'process.command_line': |
| 205 | + '/opt/java/openjdk/bin/java -javaagent:/usr/src/app/opentelemetry-javaagent.jar oteldemo.AdServiceEdotSynth', |
| 206 | + 'process.executable.path': '/opt/java/openjdk/bin/java', |
| 207 | + 'process.pid': 1, |
| 208 | + 'process.runtime.description': 'Eclipse Adoptium OpenJDK 64-Bit Server VM 21.0.5+11-LTS', |
| 209 | + 'process.runtime.name': 'OpenJDK Runtime Environment', |
| 210 | + 'process.runtime.version': '21.0.5+11-LTS', |
| 211 | + 'service.instance.id': 'da7a8507-53be-421c-8d77-984f12397213', |
| 212 | + 'service.name': 'adservice-edot-synth', |
| 213 | + 'service.namespace': 'opentelemetry-demo', |
| 214 | + 'telemetry.distro.name': 'elastic', |
| 215 | + 'telemetry.distro.version': '1.0.1-SNAPSHOT', |
| 216 | + 'telemetry.sdk.language': 'java', |
| 217 | + 'telemetry.sdk.name': 'opentelemetry', |
| 218 | + 'telemetry.sdk.version': '1.43.0', |
| 219 | + }, |
| 220 | + // schema_url: 'https://opentelemetry.io/schemas/1.24.0', |
| 221 | + }, |
| 222 | + scope: { |
| 223 | + attributes: { |
| 224 | + 'service.framework.name': 'io.opentelemetry.grpc-1.6', |
| 225 | + 'service.framework.version': '2.9.0-alpha', |
| 226 | + }, |
| 227 | + dropped_attributes_count: 0, |
| 228 | + name: 'io.opentelemetry.grpc-1.6', |
| 229 | + // version: '2.9.0-alpha', |
| 230 | + }, |
| 231 | + span_id: '8884909eca61b9d5', |
| 232 | + status: { |
| 233 | + code: 'Unset', |
| 234 | + }, |
| 235 | + trace_id: '70219abfdc4f0e17ca0975a339c2c135', |
| 236 | + }); |
| 237 | + } |
| 238 | +} |
| 239 | + |
| 240 | +export function create(id: string): OtelEdot { |
| 241 | + return new OtelEdot({ |
| 242 | + trace_id: id, |
| 243 | + dropped_attributes_count: 0, |
| 244 | + dropped_events_count: 0, |
| 245 | + dropped_links_count: 0, |
| 246 | + }); |
| 247 | +} |
| 248 | + |
| 249 | +export const otelEdot = { |
| 250 | + create, |
| 251 | +}; |
0 commit comments