-
Notifications
You must be signed in to change notification settings - Fork 527
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
model: Align labels
field with ECS
#6633
model: Align labels
field with ECS
#6633
Conversation
labels
field with ECS
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
Updates all data streams to use the ecs defined `labels` for values that are `string` or `bool`, and adds a new field for `numeric_labels` which stores all numeric labels as `scaled_float`, using the `scaling_factor` we were using for indexes. There's a single exception for the `metrics-apm.internal` data stream, due to the fact that `dynamic` is set to `strict`, which disables the externally defined ecs labels dynamic ability. For that data stream, the field is defined as a standard field. Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
ec3cbd7
to
8117968
Compare
This pull request is now in conflicts. Could you fix it @marclop? 🙏
|
- external: ecs | ||
name: labels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have to define the field everywhere, and not use references. This data stream doesn't use strict mapping, but it does set dynamic: false
at the top level meaning labels won't be indexed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's worth opening an issue on package-spec to allow specifying the dynamic
property for external fields? Seems to me it should be reasonable to specify this:
- external: ecs
name: labels
dynamic: true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, I missed that they won't be indexed if we just reference the ecs fields like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened elastic/package-spec#251
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
Signed-off-by: Marc Lopez Rubio <[email protected]>
…to-string-and-numeric-ecs-compatible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor things, othewise LGTM.
I'd like to follow up on this by changing the Labels and NumericLabels fields to be more type-safe. Either
type APMEvent struct {
Labels map[string][]string
NumericLabels map[string][]float64
}
Or
// Labels/NumericLabels values are either always stored as arrays,
// or store as an array iff len > 1
type APMEvent struct {
Labels map[string]LabelValue
NumericLabels map[string]NumericLabelValue
}
type LabelValue struct {
Value string
Values []string // If non-nil, use this; otherwise use Value
}
type NumericLabelValue struct {
Value float64
Values []float64 // If non-nil, use this; otherwise use Value
}
But to be clear, let's do that in a followup.
Signed-off-by: Marc Lopez Rubio <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎉
Updates all data streams to use the ecs defined `labels` for values that are `string` or `bool`, and adds a new field for `numeric_labels` which stores all numeric labels as `scaled_float`, using the `scaling_factor` we were using for indexes. Signed-off-by: Marc Lopez Rubio <[email protected]> (cherry picked from commit 8be9227)
Updates all data streams to use the ecs defined `labels` for values that are `string` or `bool`, and adds a new field for `numeric_labels` which stores all numeric labels as `scaled_float`, using the `scaling_factor` we were using for indexes. Signed-off-by: Marc Lopez Rubio <[email protected]> (cherry picked from commit 8be9227)
confirmed with 50edba1 package main
import (
"fmt"
"os"
"go.elastic.co/apm"
)
func main() {
version := "undefined"
if len(os.Args) > 1 {
version = os.Args[1]
}
name := fmt.Sprintf("apm-server-%s", version)
tx := apm.DefaultTracer.StartTransaction(name, "type")
tx.Context.SetLabel("enabled", true)
tx.Context.SetLabel("string", "string")
tx.Context.SetLabel("numbers", 1234.56)
tx.End()
apm.DefaultTracer.Flush(nil)
fmt.Printf("%s: %+v\n", name, apm.DefaultTracer.Stats())
} |
Motivation/summary
Updates all data streams to use the ecs defined
labels
for values thatare
string
orbool
, and adds a new field fornumeric_labels
whichstores all numeric labels as
scaled_float
, using thescaling_factor
we were using for indexes.
There's a single exception for the
metrics-apm.internal
data stream,due to the fact that
dynamic
is set tostrict
, which disables theexternally defined ecs labels dynamic ability. For that data stream, the
field is defined as a standard field.
Checklist
- [ ] Documentation has been updatedHow to test these changes
labels
fieldnumeric_labels
.Related issues
Closes #3873