Skip to content

Commit

Permalink
Add semantic attributes section to python manual instrumentation doc (#…
Browse files Browse the repository at this point in the history
…1703)

* Add semantic attributes section to python manual instrumentation doc

* Update manual.md

* Update content/en/docs/instrumentation/python/manual.md

Co-authored-by: Srikanth Chekuri <[email protected]>

Co-authored-by: Srikanth Chekuri <[email protected]>
  • Loading branch information
cartermp and srikanthccv authored Sep 5, 2022
1 parent 0fc3d3d commit 99b2c14
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions content/en/docs/instrumentation/python/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,29 @@ current_span.set_attribute("operation.name", "Saying hello!")
current_span.set_attribute("operation.other-stuff", [1, 2, 3])
```

### Add semantic attributes

[Semantic Attributes](/docs/reference/specification/trace/semantic_conventions/) are pre-defined [Attributes](/docs/concepts/signals/traces/#attributes) that are well-known naming conventions for common kinds of data. Using Semantic Attributes lets you normalize this kind of information across your systems.

To use Semantic Attributes in Python, ensure you have the semantic convetions package:

```shell
pip install opentelemetry-semantic-conventions
```

Then you can use it in code:

```python
from opentelemetry import trace
from opentelemetry.semconv.trace import SpanAttributes

// ...

current_span = trace.get_current_span()
current_span.set_attribute(SpanAttributes.HTTP_METHOD, "GET")
current_span.set_attribute(SpanAttributes.HTTP_URL, "https://opentelemetry.io/")
```

### Adding events

An [event](/docs/concepts/signals/traces/#span-events) is a human-readable
Expand Down

0 comments on commit 99b2c14

Please sign in to comment.