Skip to content

Commit

Permalink
feat(nrdb): fix NRDB query to eliminate embeddedCharts (#1131)
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav-new-relic authored Apr 30, 2024
1 parent 2a3f9b7 commit acdbacb
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions pkg/nrdb/nrdb_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,27 @@ func (n *Nrdb) QueryWithContext(ctx context.Context, accountID int, query NRQL)
"query": query,
}

if err := n.client.NerdGraphQueryWithContext(ctx, gqlNRQLQuery, vars, &respBody); err != nil {
if err := n.client.NerdGraphQueryWithContext(ctx, gqlNrqlQuery, vars, &respBody); err != nil {
return nil, err
}

return &respBody.Actor.Account.NRQL, nil
}

func (n *Nrdb) QueryExtended(accountID int, query NRQL) (*NRDBResultContainer, error) {
return n.QueryExtendedWithContext(context.Background(), accountID, query)
}

// QueryExtendedWithContext facilitates making a NRQL query with additional options.
func (n *Nrdb) QueryExtendedWithContext(ctx context.Context, accountID int, query NRQL) (*NRDBResultContainer, error) {
respBody := gqlNRQLQueryResponse{}

vars := map[string]interface{}{
"accountId": accountID,
"query": query,
}

if err := n.client.NerdGraphQueryWithContext(ctx, gqlNRQLQueryExtended, vars, &respBody); err != nil {
return nil, err
}

Expand Down Expand Up @@ -90,7 +110,12 @@ const gqlNRQLQueryHistoryQuery = `
}
}`

const gqlNRQLQuery = `query(
const gqlNrqlQuery = `query($query: Nrql!, $accountId: Int!) { actor { account(id: $accountId) { nrql(query: $query) {
currentResults otherResult previousResults results totalResult
metadata { eventTypes facets messages timeWindow { begin compareWith end since until } }
} } } }`

const gqlNRQLQueryExtended = `query(
$query: Nrql!,
$accountId: Int!
)
Expand Down

0 comments on commit acdbacb

Please sign in to comment.