Skip to content
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

[Integration][New Relic] - Add support for service level #840

Merged
merged 23 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions integrations/newrelic/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- towncrier release notes start -->

# Port_Ocean 0.1.65 (2024-08-01)
# Port_Ocean 0.1.70 (2024-08-15)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

## 0.1.70 (2024-08-15)



### Improvements

- Added support for service level indicators and objectives


# Port_Ocean 0.1.64 (2024-07-31)
## 0.1.69 (2024-08-13)


### Improvements

- Bumped ocean version to ^0.9.13 (#1)


## 0.1.68 (2024-08-11)


### Improvements

- Bumped ocean version to ^0.9.12 (#1)


## 0.1.67 (2024-08-05)


### Improvements

- Bumped ocean version to ^0.9.11 (#1)


## 0.1.66 (2024-08-04)


### Improvements

- Bumped ocean version to ^0.9.10 (#1)


## 0.1.65 (2024-08-01)

### Improvements

- Added _target='blank' attribute to html links in the spec.yaml file to open a new browser tab instead of the current browser


## 0.1.64 (2024-07-31)

### Improvements

Expand Down
8 changes: 4 additions & 4 deletions integrations/newrelic/newrelic_integration/core/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
LIST_ENTITIES_BY_GUIDS_QUERY,
GET_ENTITY_BY_GUID_QUERY,
)
from newrelic_integration.core.utils import send_graph_api_request
from newrelic_integration.core.utils import send_graph_api_request, format_tags
from newrelic_integration.utils import (
get_port_resource_configuration_by_port_kind,
render_query,
Expand All @@ -34,7 +34,7 @@ async def get_entity(self, entity_guid: str) -> dict[Any, Any]:
raise NewRelicNotFoundError(
f"No entity found in newrelic for guid {entity_guid}",
)
self._format_tags(entity)
format_tags(entity)
return entity

async def list_entities_by_resource_kind(
Expand Down Expand Up @@ -74,7 +74,7 @@ async def extract_entities(
entity_query_filter=resource_config.selector.entity_query_filter,
extra_entity_properties=resource_config.selector.entity_extra_properties_query,
):
self._format_tags(entity)
format_tags(entity)
yield entity

async def list_entities_by_guids(
Expand All @@ -92,7 +92,7 @@ async def list_entities_by_guids(
)
entities = response.get("data", {}).get("actor", {}).get("entities", [])
for entity in entities:
self._format_tags(entity)
format_tags(entity)
return entities

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
LIST_SLOS_QUERY,
GET_SLI_BY_NRQL_QUERY,
)
from newrelic_integration.core.utils import send_graph_api_request
from newrelic_integration.core.utils import send_graph_api_request, format_tags
from newrelic_integration.utils import (
render_query,
)
Expand Down Expand Up @@ -55,7 +55,7 @@ async def enrich_slo_with_sli_and_tags(
service_level[SLI_OBJECT] = await self.get_service_level_indicator_value(
self.http_client, nrql
)
self._format_tags(service_level)
format_tags(service_level)
return service_level

async def list_service_levels(self) -> AsyncIterable[list[dict[str, Any]]]:
Expand Down Expand Up @@ -87,8 +87,3 @@ async def _extract_service_levels(
.get("results", {})
)
return results.get("nextCursor"), results.get("entities", [])

@staticmethod
def _format_tags(entity: dict[Any, Any]) -> dict[Any, Any]:
entity["tags"] = {tag["key"]: tag["values"] for tag in entity.get("tags", [])}
return entity
5 changes: 5 additions & 0 deletions integrations/newrelic/newrelic_integration/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ async def send_graph_api_request(
logger.debug("Received graph api response", **log_fields)
response.raise_for_status()
return response.json()


def format_tags(entity: dict[Any, Any]) -> dict[Any, Any]:
entity["tags"] = {tag["key"]: tag["values"] for tag in entity.get("tags", [])}
return entity
4 changes: 2 additions & 2 deletions integrations/newrelic/newrelic_integration/ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
get_port_resource_configuration_by_port_kind,
)

MAX_CONCURRENT_REQUESTS = 10
SERVICE_LEVEL_MAX_CONCURRENT_REQUESTS = 10


async def enrich_service_level(
Expand Down Expand Up @@ -82,7 +82,7 @@ async def resync_service_levels(kind: str) -> ASYNC_GENERATOR_RESYNC_TYPE:
with logger.contextualize(resource_kind=kind):
async with httpx.AsyncClient() as http_client:
service_level_handler = ServiceLevelsHandler(http_client)
semaphore = asyncio.Semaphore(MAX_CONCURRENT_REQUESTS)
semaphore = asyncio.Semaphore(SERVICE_LEVEL_MAX_CONCURRENT_REQUESTS)

async for service_levels in service_level_handler.list_service_levels():
tasks = [
Expand Down
2 changes: 1 addition & 1 deletion integrations/newrelic/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "newrelic"
version = "0.1.65"
version = "0.1.70"
description = "New Relic Integration"
authors = ["Tom Tankilevitch <[email protected]>"]

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.