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

feat(core): Add metric summaries to spans #10432

Merged
merged 12 commits into from
Feb 5, 2024

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Jan 30, 2024

A quick PoC for #10059

I read the RFC, but it's almost entirely inspired by the Python implementation.

Outstanding issues:

  • Summaries are only attached to spans, should they also be attached to the root transaction, ie. in contexts.trace._metrics_summary?
  • We only add to the summaries when value: number and ignore metrics with value: string. It looks like this didn't come up in Python
  • The Python code used type:name@unit as the key for each metric summary. If the unit is not set, I guess we drop @metric from the end? The integration test I added has @undefined 😆
  • No idea how this will work yet post v8 in node where the spans are otel spans!
  • I haven't tested this against sentry.io yet but the envelopes look correct

@AbhiPrasad

This comment was marked as resolved.

@AbhiPrasad
Copy link
Member

The Python code used type:name@unit as the key for each metric summary. If the unit is not set, I guess we drop @Metric from the end? The integration test I added has @undefined 😆

Yes I think we can drop @unit if the unit is not set.

No idea how this will work yet post v8 in node where the spans are otel spans!

Yeah this is TBD, but I think we might be able to hack span events to do this!

@AbhiPrasad

This comment was marked as resolved.

packages/core/src/metric-summary.ts Outdated Show resolved Hide resolved
packages/core/src/metric-summary.ts Outdated Show resolved Hide resolved
@timfish

This comment was marked as outdated.

@timfish timfish marked this pull request as ready for review February 1, 2024 00:13
@timfish timfish requested a review from cleptric February 1, 2024 00:47
@timfish

This comment was marked as resolved.

@AbhiPrasad
Copy link
Member

image

Tested on Sentry and all seems good!

@AbhiPrasad AbhiPrasad merged commit 94cdd8b into getsentry:develop Feb 5, 2024
99 checks passed
AbhiPrasad added a commit that referenced this pull request Feb 5, 2024
AbhiPrasad added a commit that referenced this pull request Feb 5, 2024
This reverts commit 94cdd8b.

I mistakenly merged this - we have to fix the metric summaries format.

Summaries are typed as `pub type MetricSummaryMapping =
Object<Array<MetricSummary>>;`

Which means that the `_metrics_summary` type needs to be
`_metrics_summary?: Record<string, Array<MetricSummary>>;`. This is
because we need to create separate entries if the tags have changed.

```
"c:processor.item_processed": [
    {
        "min": 1,
        "max": 1,
        "count": 3,
        "sum": 3,
        "tags": {"success": true}
    },
    {
        "min": 1,
        "max": 1,
        "count": 2,
        "sum": 2,
        "tags": {"success": false}
    }
],
```
@AbhiPrasad
Copy link
Member

Had to revert this - #10495

const EXPECTED_TRANSACTION = {
transaction: 'Test Transaction',
_metrics_summary: {
'c:root-counter@none': {
Copy link
Member

Choose a reason for hiding this comment

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

this needs to be an array of metrics, based on what tags it has.

cleptric added a commit that referenced this pull request Feb 7, 2024
…10495)"

This reverts commit 60a7d65.

# Conflicts:
#	packages/types/src/event.ts
cleptric added a commit that referenced this pull request Feb 8, 2024
…10495)"

This reverts commit 60a7d65.

# Conflicts:
#	packages/types/src/event.ts
cleptric added a commit that referenced this pull request Feb 8, 2024
…10495)"

This reverts commit 60a7d65.

# Conflicts:
#	packages/types/src/event.ts
@timfish timfish deleted the feat/metric-summaries branch February 19, 2024 15:47
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.

None yet

3 participants