Skip to content

Commit 30a1aff

Browse files
authored
[monitor-opentelemetry] Update Monitor README (Azure#26780)
### Packages impacted by this PR - @azure/monitor-opentelemetry ### Issues associated with this PR - Azure#26754 ### Describe the problem that is addressed by this PR Updates the README with a cast to the proper type. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [x] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
1 parent 8464c59 commit 30a1aff

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

sdk/monitor/monitor-opentelemetry/README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,26 +214,28 @@ Use a custom processor:
214214
```typescript
215215
const { AzureMonitorOpenTelemetryClient } = require("@azure/monitor-opentelemetry");
216216
const { ReadableSpan, Span, SpanProcessor } = require("@opentelemetry/sdk-trace-base");
217+
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
217218
const { SemanticAttributes } = require("@opentelemetry/semantic-conventions");
218219

219220
const azureMonitorClient = new AzureMonitorOpenTelemetryClient();
220221

221222
class SpanEnrichingProcessor implements SpanProcessor{
222-
forceFlush(): Promise<void>{
223-
return Promise.resolve();
224-
}
225-
shutdown(): Promise<void>{
226-
return Promise.resolve();
227-
}
228-
onStart(_span: Span): void{}
229-
onEnd(span: ReadableSpan){
230-
span.attributes["CustomDimension1"] = "value1";
231-
span.attributes["CustomDimension2"] = "value2";
232-
span.attributes[SemanticAttributes.HTTP_CLIENT_IP] = "<IP Address>";
233-
}
223+
forceFlush(): Promise<void>{
224+
return Promise.resolve();
225+
}
226+
shutdown(): Promise<void>{
227+
return Promise.resolve();
228+
}
229+
onStart(_span: Span): void{}
230+
onEnd(span: ReadableSpan){
231+
span.attributes["CustomDimension1"] = "value1";
232+
span.attributes["CustomDimension2"] = "value2";
233+
span.attributes[SemanticAttributes.HTTP_CLIENT_IP] = "<IP Address>";
234+
}
234235
}
235236

236-
azureMonitorClient.getTracerProvider().addSpanProcessor(new SpanEnrichingProcessor());
237+
const tracerProvider = azureMonitorClient.getTracerProvider() as NodeTracerProvider;
238+
tracerProvider.addSpanProcessor(new SpanEnrichingProcessor());
237239
```
238240

239241
### Filter telemetry

0 commit comments

Comments
 (0)