Skip to content

Commit

Permalink
feat(entities): Add some more details from BrowserApplicationEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Thurman committed Mar 11, 2020
1 parent 02269f9 commit fb5a50b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
42 changes: 30 additions & 12 deletions pkg/entities/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@ import (
type Entity struct {
AccountID int `json:"accountId,omitempty"`
Domain EntityDomainType `json:"domain,omitempty"`
EntityType EntityType `json:"entityType,omitempty"` // This does not match what EntityTypes below (is full name not short)
EntityType EntityType `json:"entityType,omitempty"` // Full Type (ie APM_APPLICATION_ENTITY)
GUID string `json:"guid,omitempty"`
Name string `json:"name,omitempty"`
Permalink string `json:"permalink,omitempty"`
Reporting bool `json:"reporting,omitempty"`
Type string `json:"type,omitempty"` // TODO: Should be a type (or EntityType?) Vet what that breaks
Type EntityType `json:"type,omitempty"`

// Not always returned. Only returned from ApmApplicationEntityOutline
AlertSeverity *EntityAlertSeverityType `json:"alertSeverity,omitempty"`
ApplicationID *int `json:"applicationId,omitempty"`
// ApmApplicationEntity, BrowserApplicationEntity
AlertSeverity *EntityAlertSeverityType `json:"alertSeverity,omitempty"`
ApplicationID *int `json:"applicationId,omitempty"`

// ApmApplicationEntity
Language *string `json:"language,omitempty"`
RunningAgentVersions *ApmApplicationEntityOutlineRunningAgentVersions `json:"runningAgentVersions,omitempty"`
Settings *ApmApplicationEntityOutlineSettings `json:"settings,omitempty"`

// BrowserApplicationEntity
ServingApmApplicationID *int `json:"servingApmApplicationId,omitempty"`
}

type ApmApplicationEntityOutlineSettings struct {
Expand Down Expand Up @@ -192,6 +197,7 @@ const (
graphqlApmApplicationEntityOutlineFields = `
... on ApmApplicationEntityOutline {
applicationId
alertSeverity
language
runningAgentVersions {
maxVersion
Expand All @@ -203,14 +209,30 @@ const (
}
}`

graphqlBrowserApplicationEntityFields = `
... on BrowserApplicationEntity {
alertSeverity
applicationId
servingApmApplicationId
}`

graphqlBrowserApplicationEntityOutlineFields = `
... on BrowserApplicationEntityOutline {
alertSeverity
applicationId
servingApmApplicationId
}`

getEntitiesQuery = `query($guids: [String!]!) { actor { entities(guids: $guids) {` +
graphqlEntityStructFields +
graphqlApmApplicationEntityFields +
graphqlBrowserApplicationEntityFields +
` } } }`

getEntityQuery = `query($guid: String!) { actor { entity(guid: $guid) {` +
graphqlEntityStructFields +
graphqlApmApplicationEntityFields +
graphqlBrowserApplicationEntityFields +
` } } }`

searchEntitiesQuery = `
Expand All @@ -221,13 +243,9 @@ const (
nextCursor
entities {` +
graphqlEntityStructFields +
graphqlApmApplicationEntityOutlineFields + `
}
}
}
}
}
`
graphqlApmApplicationEntityOutlineFields +
graphqlBrowserApplicationEntityOutlineFields +
` } } } } }`
)

type searchEntitiesResponse struct {
Expand Down
3 changes: 1 addition & 2 deletions pkg/entities/entity_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@ func TestIntegrationGetEntity(t *testing.T) {
assert.Equal(t, 2520528, actual.AccountID)
assert.Equal(t, EntityDomainType("APM"), actual.Domain)
assert.Equal(t, EntityType("APM_APPLICATION_ENTITY"), actual.EntityType)
assert.Equal(t, "APPLICATION", actual.Type)
assert.Equal(t, entityGUID, actual.GUID)
assert.Equal(t, "Dummy App", actual.Name)
assert.Equal(t, "https://one.newrelic.com/redirect/entity/"+entityGUID, actual.Permalink)
assert.Equal(t, true, actual.Reporting)
assert.Equal(t, "APPLICATION", actual.Type)
assert.Equal(t, EntityType("APPLICATION"), actual.Type)
}

// Looking at an APM Application, and the result set here.
Expand Down

0 comments on commit fb5a50b

Please sign in to comment.