Skip to content

Commit

Permalink
[monitor-opentelemetry] Update Monitor README (#26780)
Browse files Browse the repository at this point in the history
### Packages impacted by this PR

- @azure/monitor-opentelemetry

### Issues associated with this PR

- #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)
  • Loading branch information
mpodwysocki authored Aug 11, 2023
1 parent 8464c59 commit 30a1aff
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions sdk/monitor/monitor-opentelemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,26 +214,28 @@ Use a custom processor:
```typescript
const { AzureMonitorOpenTelemetryClient } = require("@azure/monitor-opentelemetry");
const { ReadableSpan, Span, SpanProcessor } = require("@opentelemetry/sdk-trace-base");
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node");
const { SemanticAttributes } = require("@opentelemetry/semantic-conventions");

const azureMonitorClient = new AzureMonitorOpenTelemetryClient();

class SpanEnrichingProcessor implements SpanProcessor{
forceFlush(): Promise<void>{
return Promise.resolve();
}
shutdown(): Promise<void>{
return Promise.resolve();
}
onStart(_span: Span): void{}
onEnd(span: ReadableSpan){
span.attributes["CustomDimension1"] = "value1";
span.attributes["CustomDimension2"] = "value2";
span.attributes[SemanticAttributes.HTTP_CLIENT_IP] = "<IP Address>";
}
forceFlush(): Promise<void>{
return Promise.resolve();
}
shutdown(): Promise<void>{
return Promise.resolve();
}
onStart(_span: Span): void{}
onEnd(span: ReadableSpan){
span.attributes["CustomDimension1"] = "value1";
span.attributes["CustomDimension2"] = "value2";
span.attributes[SemanticAttributes.HTTP_CLIENT_IP] = "<IP Address>";
}
}

azureMonitorClient.getTracerProvider().addSpanProcessor(new SpanEnrichingProcessor());
const tracerProvider = azureMonitorClient.getTracerProvider() as NodeTracerProvider;
tracerProvider.addSpanProcessor(new SpanEnrichingProcessor());
```

### Filter telemetry
Expand Down

0 comments on commit 30a1aff

Please sign in to comment.