Skip to content

Commit

Permalink
refactor(examples/opentelemetry-web): use new exported string constan…
Browse files Browse the repository at this point in the history
…ts for semconv
  • Loading branch information
Zen-cronic committed Jun 4, 2024
1 parent 315239d commit 96cca4e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 6 deletions.
8 changes: 7 additions & 1 deletion examples/opentelemetry-web/examples/fetch-proto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ const { ZoneContextManager } = require("@opentelemetry/context-zone");
const { B3Propagator } = require("@opentelemetry/propagator-b3");
const { registerInstrumentations } = require("@opentelemetry/instrumentation");
const { OTLPTraceExporter: OTLPTraceExporterProto } = require("@opentelemetry/exporter-trace-otlp-proto");
const { Resource } = require("@opentelemetry/resources");
const { SEMRESATTRS_SERVICE_NAME } = require("@opentelemetry/semantic-conventions");

const provider = new WebTracerProvider();
const provider = new WebTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'fetch-proto-web-service'
})
});

// Note: For production consider using the "BatchSpanProcessor" to reduce the number of requests
// to your exporter. Using the SimpleSpanProcessor here as it sends the spans immediately to the
Expand Down
8 changes: 7 additions & 1 deletion examples/opentelemetry-web/examples/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ const { FetchInstrumentation } = require( '@opentelemetry/instrumentation-fetch'
const { ZoneContextManager } = require( '@opentelemetry/context-zone');
const { B3Propagator } = require( '@opentelemetry/propagator-b3');
const { registerInstrumentations } = require( '@opentelemetry/instrumentation');
const { Resource } = require('@opentelemetry/resources');
const { SEMRESATTRS_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

const provider = new WebTracerProvider();
const provider = new WebTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'fetch-web-service'
})
});

// Note: For production consider using the "BatchSpanProcessor" to reduce the number of requests
// to your exporter. Using the SimpleSpanProcessor here as it sends the spans immediately to the
Expand Down
8 changes: 7 additions & 1 deletion examples/opentelemetry-web/examples/fetchXhr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ const { FetchInstrumentation } = require('@opentelemetry/instrumentation-fetch')
const { XMLHttpRequestInstrumentation } = require('@opentelemetry/instrumentation-xml-http-request');
const { ZoneContextManager } = require('@opentelemetry/context-zone');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { Resource } = require('@opentelemetry/resources');
const { SEMRESATTRS_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

const provider = new WebTracerProvider();
const provider = new WebTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'fetch-xhr-web-service'
})
});

// Note: For production consider using the "BatchSpanProcessor" to reduce the number of requests
// to your exporter. Using the SimpleSpanProcessor here as it sends the spans immediately to the
Expand Down
8 changes: 7 additions & 1 deletion examples/opentelemetry-web/examples/fetchXhrB3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ const { XMLHttpRequestInstrumentation } = require( '@opentelemetry/instrumentati
const { ZoneContextManager } = require( '@opentelemetry/context-zone');
const { B3Propagator } = require( '@opentelemetry/propagator-b3');
const { registerInstrumentations } = require( '@opentelemetry/instrumentation');
const { Resource } = require('@opentelemetry/resources');
const { SEMRESATTRS_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

const provider = new WebTracerProvider();
const provider = new WebTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'fetch-xhr-b3-web-service'
})
});

// Note: For production consider using the "BatchSpanProcessor" to reduce the number of requests
// to your exporter. Using the SimpleSpanProcessor here as it sends the spans immediately to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ const { ZoneContextManager } = require( '@opentelemetry/context-zone');
const { OTLPTraceExporter } = require( '@opentelemetry/exporter-trace-otlp-http');
const { B3Propagator } = require( '@opentelemetry/propagator-b3');
const { registerInstrumentations } = require( '@opentelemetry/instrumentation');
const { Resource } = require('@opentelemetry/resources');
const { SEMRESATTRS_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

const providerWithZone = new WebTracerProvider();
const providerWithZone = new WebTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'xml-http-web-service'
})
});

// Note: For production consider using the "BatchSpanProcessor" to reduce the number of requests
// to your exporter. Using the SimpleSpanProcessor here as it sends the spans immediately to the
Expand Down
9 changes: 8 additions & 1 deletion examples/opentelemetry-web/examples/zipkin/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
const { ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
const { WebTracerProvider } = require('@opentelemetry/sdk-trace-web');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const { Resource } = require('@opentelemetry/resources');
const { SEMRESATTRS_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');

const provider = new WebTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'zipkin-web-service'
})
});

const provider = new WebTracerProvider();
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter({
// testing interceptor
Expand Down

0 comments on commit 96cca4e

Please sign in to comment.