Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs about map fields #65

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Add docs about map fields #65

wants to merge 8 commits into from

Conversation

c-ehrlich
Copy link
Contributor

@c-ehrlich c-ehrlich commented Sep 12, 2024

@tothmano tothmano marked this pull request as ready for review November 6, 2024 10:59
@tothmano tothmano requested a review from mhr3 November 6, 2024 10:59
@tothmano tothmano self-assigned this Nov 6, 2024
@tothmano
Copy link
Collaborator

tothmano commented Nov 6, 2024

@c-ehrlich This looks great! Thank you so much for writing up the base.
@mhr3 I've restructured the document based on your comments. Could you please take a final look?

@tothmano tothmano changed the title create very rough first draft of map fields docs Add docs about map fields Nov 7, 2024

If you are ingesting tracing data using the [OTLP/HTTP endpoint for traces and logs](/send-data/opentelemetry), you may have noticed that some attributes are moved into the `attributes.custom` map field.
The benefit of map fields is that you can store additional attributes without adding more fields. This is particularly useful when the shape of your data is unpredictable (for example, additional attributes added by an OpenTelemetry instrumentation). Using map fields means that you can avoid reaching the field limit of a dataset and improve query performance.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"by OpenTelemetry instrumentation" sounds more natural i think


```kusto
['otel-demo-traces']
| where ['attributes.http.url'] == 'http://opentelemetry-demo-frontendproxy:8080/api/cart'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a string field, not a map (given it's being compared against a string value)


[Run in playground](https://play.axiom.co/axiom-play-qf1k/explorer?initForm=%7b%22apl%22%3a%22%5b%27otel-demo-traces%27%5d%5cn%7c%20where%20%5b%27attributes.http.url%27%5d%20%3d%3d%20%27http%3a%2f%2fopentelemetry-demo-frontendproxy%3a8080%2fapi%2fcart%27%22%2c%22queryOptions%22%3a%7b%22quickRange%22%3a%2230d%22%7d%7d)

To access `http.protocol` inside the `attributes.custom` map field, use the syntax `['MAP_FIELD_NAME']['INDEX_TO_MAP_FIELD']` instead:
Copy link
Contributor

@mhr3 mhr3 Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bracketing only needs to happen when there's dots (or other special chars) in the name

if the field is called for example attrs and the property foo, attrs.foo is perfectly valid (but of course ['attrs']['foo'] also works, and so would attrs['foo'] or ['attrs'].foo)


Map fields are a special type of field that can hold a collection of nested key-value pairs within a single field. You can think of the content of a map field as a JSON object.

## Benefits of map fields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should also mention drawbacks - querying them uses more query gbms, there's no visibility into them from the schema (ie autocomplete will not know what properties are inside the map)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants