Skip to content

Commit

Permalink
Add other exportes example (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorhdzg committed May 8, 2023
1 parent a005c28 commit 08648d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ Other OpenTelemetry Instrumentations are available [here](https://github.com/ope

```

## Add other OpenTelemetry Exporters

You can include other OpenTelemetry Exporters adding a new SpanProcessor to the TracerProvider created internally:

```typescript
const { ApplicationInsightsClient, ApplicationInsightsConfig } = require("applicationinsights");
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { BatchSpanProcessor } = require("@opentelemetry/sdk-trace-base");

const appInsights = new ApplicationInsightsClient(new ApplicationInsightsConfig());
const otlpExporter = new OTLPTraceExporter(collectorOptions);
const spanProcessor = new BatchSpanProcessor(otlpExporter);
appInsights.getTraceHandler().addSpanProcessor(spanProcessor);
```

## Set the Cloud Role Name and the Cloud Role Instance

You might set the Cloud Role Name and the Cloud Role Instance via [OpenTelemetry Resource](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#resource-sdk) attributes. This step updates Cloud Role Name and Cloud Role Instance from their default values to something that makes sense to your team. They'll appear on the Application Map as the name underneath a node. Cloud Role Name uses `service.namespace` and `service.name` attributes, although it falls back to `service.name` if `service.namespace` isn't set. Cloud Role Instance uses the `service.instance.id` attribute value.
Expand Down
3 changes: 1 addition & 2 deletions src/traces/traceHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { BatchSpanProcessor, BufferConfig, SpanProcessor, Tracer } from "@opente
import { HttpInstrumentation, HttpInstrumentationConfig, IgnoreOutgoingRequestFunction } from "@opentelemetry/instrumentation-http";
import { ApplicationInsightsSampler } from "./applicationInsightsSampler";
import { ApplicationInsightsConfig } from "../shared";
import { TracerProvider } from "@opentelemetry/api";
import { MetricHandler } from "../metrics/metricHandler";
import { AzureSpanProcessor } from "./azureSpanProcessor";
import { AzureFunctionsHook } from "./azureFunctionsHook";
Expand Down Expand Up @@ -88,7 +87,7 @@ export class TraceHandler {
// No Op
}

public getTracerProvider(): TracerProvider {
public getTracerProvider(): NodeTracerProvider {
return this._tracerProvider;
}

Expand Down

0 comments on commit 08648d9

Please sign in to comment.