Skip to content

Wrong current observation is set during DataFetcher execution #757

Closed
@MarekSvatos

Description

@MarekSvatos

Hi I’m trying out Micrometer Tracing with Spring GraphQL.

Schema:

type Query{
    playlists: [Playlist]
}

type Playlist {
    id: ID!
    name: String!
    tracks: [Track]
    artists: [Artist]
}

type Track{
    id :ID!
    name: String!
    year: Int!
    artists: [Artist]
}

type Artist{
    id: ID!
    name: String!
}

Schema mappings:

   @QueryMapping
   public List<Playlist> playlists() {
       return playlistService.getAll();
   }

   @BatchMapping(typeName = "Playlist", field = "artists")
   public Map<Playlist, List<Artist>> playlistArtists(final List<Playlist> playlists) {
       return artistService.getArtistsForPlaylists(playlists);
   }

   @BatchMapping(typeName = "Playlist", field = "tracks")
   public Map<Playlist, List<Track>> playlistTracks(final List<Playlist> playlists) {
       return tracksService.getTracks(playlists);
   }

   @BatchMapping(typeName = "Track", field = "artists")
   public Map<Track, List<Artist>> trackArtists(final List<Track> tracks) {
       return artistService.getArtistsForTracks(tracks);
   }

TrackService calls remote service via REST(Spring Cloud Feign)

ArtistService calls remote service via GRPC

Spans with calls to remote services are children of ‘graphql query’ span but they fetch data for tracks and artists fields. I would expect some correlation between the field span and batched request.

If I use @SchemaMapping instead of @BatchMapping and fetch tracks for each playlist individually the span which calls to trackService is still only child of ‘graphql field playlists’ and not ‘graphql field tracks’, which is kind of confusing to me.

Trace with BatchMapping:
batched
Trace with SchemaMapping:

not-batched

Could you please clarify if this is intended behaviour? Thank you.

Metadata

Metadata

Assignees

Labels

in: coreIssues related to config and core supportstatus: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions