@@ -12,6 +12,7 @@ import (
1212 v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
1313
1414 "github.com/authzed/spicedb/internal/datastore/common"
15+ "github.com/authzed/spicedb/internal/telemetry/otelconv"
1516 "github.com/authzed/spicedb/pkg/datastore"
1617 "github.com/authzed/spicedb/pkg/datastore/options"
1718 core "github.com/authzed/spicedb/pkg/proto/core/v1"
@@ -97,7 +98,7 @@ func (p *observableProxy) OptimizedRevision(ctx context.Context) (datastore.Revi
9798
9899func (p * observableProxy ) CheckRevision (ctx context.Context , revision datastore.Revision ) error {
99100 ctx , closer := observe (ctx , "CheckRevision" , "" , trace .WithAttributes (
100- attribute .String ("revision" , revision .String ()),
101+ attribute .String (otelconv . AttrDatastoreRevision , revision .String ()),
101102 ))
102103 defer closer ()
103104
@@ -154,7 +155,7 @@ type observableReader struct{ delegate datastore.Reader }
154155
155156func (r * observableReader ) CountRelationships (ctx context.Context , name string ) (int , error ) {
156157 ctx , closer := observe (ctx , "CountRelationships" , "" , trace .WithAttributes (
157- attribute .String ( "name" , name ),
158+ attribute .StringSlice ( otelconv . AttrDatastoreNames , [] string { name } ),
158159 ))
159160 defer closer ()
160161
@@ -170,7 +171,7 @@ func (r *observableReader) LookupCounters(ctx context.Context) ([]datastore.Rela
170171
171172func (r * observableReader ) ReadCaveatByName (ctx context.Context , name string ) (* core.CaveatDefinition , datastore.Revision , error ) {
172173 ctx , closer := observe (ctx , "ReadCaveatByName" , "" , trace .WithAttributes (
173- attribute .String ( "name" , name ),
174+ attribute .StringSlice ( otelconv . AttrDatastoreNames , [] string { name } ),
174175 ))
175176 defer closer ()
176177
@@ -179,7 +180,7 @@ func (r *observableReader) ReadCaveatByName(ctx context.Context, name string) (*
179180
180181func (r * observableReader ) LookupCaveatsWithNames (ctx context.Context , caveatNames []string ) ([]datastore.RevisionedCaveat , error ) {
181182 ctx , closer := observe (ctx , "LookupCaveatsWithNames" , "" , trace .WithAttributes (
182- attribute .StringSlice ("names" , caveatNames ),
183+ attribute .StringSlice (otelconv . AttrDatastoreNames , caveatNames ),
183184 ))
184185 defer closer ()
185186
@@ -202,7 +203,7 @@ func (r *observableReader) ListAllNamespaces(ctx context.Context) ([]datastore.R
202203
203204func (r * observableReader ) LookupNamespacesWithNames (ctx context.Context , nsNames []string ) ([]datastore.RevisionedNamespace , error ) {
204205 ctx , closer := observe (ctx , "LookupNamespacesWithNames" , "" , trace .WithAttributes (
205- attribute .StringSlice ("names" , nsNames ),
206+ attribute .StringSlice (otelconv . AttrDatastoreNames , nsNames ),
206207 ))
207208 defer closer ()
208209
@@ -211,7 +212,7 @@ func (r *observableReader) LookupNamespacesWithNames(ctx context.Context, nsName
211212
212213func (r * observableReader ) ReadNamespaceByName (ctx context.Context , nsName string ) (* core.NamespaceDefinition , datastore.Revision , error ) {
213214 ctx , closer := observe (ctx , "ReadNamespaceByName" , "" , trace .WithAttributes (
214- attribute .String ( "name" , nsName ),
215+ attribute .StringSlice ( otelconv . AttrDatastoreNames , [] string { nsName } ),
215216 ))
216217 defer closer ()
217218
@@ -221,9 +222,9 @@ func (r *observableReader) ReadNamespaceByName(ctx context.Context, nsName strin
221222func (r * observableReader ) QueryRelationships (ctx context.Context , filter datastore.RelationshipsFilter , opts ... options.QueryOptionsOption ) (datastore.RelationshipIterator , error ) {
222223 queryOpts := options .NewQueryOptionsWithOptions (opts ... )
223224 ctx , closer := observe (ctx , "QueryRelationships" , string (queryOpts .QueryShape ), trace .WithAttributes (
224- attribute .String ("resourceType" , filter .OptionalResourceType ),
225- attribute .String ("resourceRelation" , filter .OptionalResourceRelation ),
226- attribute .String ("queryShape" , string (queryOpts .QueryShape )),
225+ attribute .String (otelconv . AttrDatastoreResourceType , filter .OptionalResourceType ),
226+ attribute .String (otelconv . AttrDatastoreResourceRelation , filter .OptionalResourceRelation ),
227+ attribute .String (otelconv . AttrDatastoreQueryShape , string (queryOpts .QueryShape )),
227228 ))
228229
229230 iterator , err := r .delegate .QueryRelationships (ctx , filter , opts ... )
@@ -249,8 +250,8 @@ func (r *observableReader) QueryRelationships(ctx context.Context, filter datast
249250func (r * observableReader ) ReverseQueryRelationships (ctx context.Context , subjectsFilter datastore.SubjectsFilter , opts ... options.ReverseQueryOptionsOption ) (datastore.RelationshipIterator , error ) {
250251 queryOpts := options .NewReverseQueryOptionsWithOptions (opts ... )
251252 ctx , closer := observe (ctx , "ReverseQueryRelationships" , string (queryOpts .QueryShapeForReverse ), trace .WithAttributes (
252- attribute .String ("subjectType" , subjectsFilter .SubjectType ),
253- attribute .String ("queryShape" , string (queryOpts .QueryShapeForReverse ))))
253+ attribute .String (otelconv . AttrDatastoreSubjectType , subjectsFilter .SubjectType ),
254+ attribute .String (otelconv . AttrDatastoreQueryShape , string (queryOpts .QueryShapeForReverse ))))
254255
255256 iterator , err := r .delegate .ReverseQueryRelationships (ctx , subjectsFilter , opts ... )
256257 if err != nil {
@@ -279,7 +280,7 @@ type observableRWT struct {
279280
280281func (rwt * observableRWT ) RegisterCounter (ctx context.Context , name string , filter * core.RelationshipFilter ) error {
281282 ctx , closer := observe (ctx , "RegisterCounter" , "" , trace .WithAttributes (
282- attribute .String ( "name" , name ),
283+ attribute .StringSlice ( otelconv . AttrDatastoreNames , [] string { name } ),
283284 ))
284285 defer closer ()
285286
@@ -288,7 +289,7 @@ func (rwt *observableRWT) RegisterCounter(ctx context.Context, name string, filt
288289
289290func (rwt * observableRWT ) UnregisterCounter (ctx context.Context , name string ) error {
290291 ctx , closer := observe (ctx , "UnregisterCounter" , "" , trace .WithAttributes (
291- attribute .String ( "name" , name ),
292+ attribute .StringSlice ( otelconv . AttrDatastoreNames , [] string { name } ),
292293 ))
293294 defer closer ()
294295
@@ -297,9 +298,9 @@ func (rwt *observableRWT) UnregisterCounter(ctx context.Context, name string) er
297298
298299func (rwt * observableRWT ) StoreCounterValue (ctx context.Context , name string , value int , computedAtRevision datastore.Revision ) error {
299300 ctx , closer := observe (ctx , "StoreCounterValue" , "" , trace .WithAttributes (
300- attribute .String ( "name" , name ),
301- attribute .Int ("value" , value ),
302- attribute .String ("revision" , computedAtRevision .String ()),
301+ attribute .StringSlice ( otelconv . AttrDatastoreNames , [] string { name } ),
302+ attribute .Int (otelconv . AttrDatastoreValue , value ),
303+ attribute .String (otelconv . AttrDatastoreRevision , computedAtRevision .String ()),
303304 ))
304305 defer closer ()
305306
@@ -313,7 +314,7 @@ func (rwt *observableRWT) WriteCaveats(ctx context.Context, caveats []*core.Cave
313314 }
314315
315316 ctx , closer := observe (ctx , "WriteCaveats" , "" , trace .WithAttributes (
316- attribute .StringSlice ("names" , caveatNames ),
317+ attribute .StringSlice (otelconv . AttrDatastoreNames , caveatNames ),
317318 ))
318319 defer closer ()
319320
@@ -322,7 +323,7 @@ func (rwt *observableRWT) WriteCaveats(ctx context.Context, caveats []*core.Cave
322323
323324func (rwt * observableRWT ) DeleteCaveats (ctx context.Context , names []string ) error {
324325 ctx , closer := observe (ctx , "DeleteCaveats" , "" , trace .WithAttributes (
325- attribute .StringSlice ("names" , names ),
326+ attribute .StringSlice (otelconv . AttrDatastoreNames , names ),
326327 ))
327328 defer closer ()
328329
@@ -331,7 +332,7 @@ func (rwt *observableRWT) DeleteCaveats(ctx context.Context, names []string) err
331332
332333func (rwt * observableRWT ) WriteRelationships (ctx context.Context , mutations []tuple.RelationshipUpdate ) error {
333334 ctx , closer := observe (ctx , "WriteRelationships" , "" , trace .WithAttributes (
334- attribute .Int ("mutations" , len (mutations )),
335+ attribute .Int (otelconv . AttrDatastoreMutations , len (mutations )),
335336 ))
336337 defer closer ()
337338
@@ -345,7 +346,7 @@ func (rwt *observableRWT) WriteNamespaces(ctx context.Context, newConfigs ...*co
345346 }
346347
347348 ctx , closer := observe (ctx , "WriteNamespaces" , "" , trace .WithAttributes (
348- attribute .StringSlice ("names" , nsNames ),
349+ attribute .StringSlice (otelconv . AttrDatastoreNames , nsNames ),
349350 ))
350351 defer closer ()
351352
@@ -354,7 +355,7 @@ func (rwt *observableRWT) WriteNamespaces(ctx context.Context, newConfigs ...*co
354355
355356func (rwt * observableRWT ) DeleteNamespaces (ctx context.Context , nsNames ... string ) error {
356357 ctx , closer := observe (ctx , "DeleteNamespaces" , "" , trace .WithAttributes (
357- attribute .StringSlice ("names" , nsNames ),
358+ attribute .StringSlice (otelconv . AttrDatastoreNames , nsNames ),
358359 ))
359360 defer closer ()
360361
0 commit comments