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

migrate sentry to config-based cdk #15345

Merged
merged 37 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
932dcac
events and projects
girarda Aug 5, 2022
0c0135b
done minus pagination
girarda Aug 5, 2022
f473dee
handle single records
girarda Aug 5, 2022
666c170
Merge branch 'master' into alex/configbased-sentry
girarda Aug 9, 2022
886c24a
pagination
girarda Aug 9, 2022
e234a8d
bump min cdk version
girarda Aug 9, 2022
4bd72f1
start on unit tests
girarda Aug 10, 2022
e1c0ae0
Update more unit tests
girarda Aug 10, 2022
42af817
Handle extracting no records from root
girarda Aug 10, 2022
1f01abc
Merge branch 'master' into alex/configbased-sentry
girarda Aug 10, 2022
ddae912
additionalProperties=true
girarda Aug 10, 2022
d1c0224
handle empty streams
girarda Aug 10, 2022
144f816
skip backward compatibility tests
girarda Aug 10, 2022
0010cf3
check on project_detail
girarda Aug 10, 2022
793521e
remove unit tests
girarda Aug 10, 2022
52d28fe
handle missing keys
girarda Aug 11, 2022
d9252ae
delete stream classes
girarda Aug 11, 2022
7975a89
Merge branch 'master' into alex/selectNoRecords
girarda Aug 11, 2022
b582e87
record extractor interface
girarda Aug 11, 2022
1b34c19
dpath extractor
girarda Aug 11, 2022
3dadc32
docstring
girarda Aug 11, 2022
5e9d9fa
handle extract root array
girarda Aug 11, 2022
bad4dd7
Merge branch 'alex/selectNoRecords' into alex/configbased-sentry
girarda Aug 11, 2022
8ed13fc
Use dpath extractor
girarda Aug 11, 2022
a53760d
Revert "Merge branch 'alex/selectNoRecords' into alex/configbased-sen…
girarda Aug 11, 2022
9cfb35d
merge
girarda Aug 11, 2022
aa0d777
reset to master
girarda Aug 11, 2022
7a443b2
reset to master
girarda Aug 11, 2022
182e4d8
reset to master
girarda Aug 11, 2022
0a9f825
enable backward compatibility test
girarda Aug 11, 2022
4f16cb9
bump cdk version
girarda Aug 11, 2022
5338da3
reset
girarda Aug 11, 2022
a2a0db8
Update airbyte-integrations/connectors/source-sentry/source_sentry/se…
girarda Aug 11, 2022
37321d6
Use paginator
girarda Aug 11, 2022
5a9bb1e
fix pagination
girarda Aug 11, 2022
8e062cb
bump version
girarda Aug 12, 2022
f4a9723
auto-bump connector version [ci skip]
octavia-squidington-iii Aug 12, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@
- sourceDefinitionId: cdaf146a-9b75-49fd-9dd2-9d64a0bb4781
name: Sentry
dockerRepository: airbyte/source-sentry
dockerImageTag: 0.1.1
dockerImageTag: 0.1.2
documentationUrl: https://docs.airbyte.io/integrations/sources/sentry
icon: sentry.svg
sourceType: api
Expand Down
4 changes: 2 additions & 2 deletions airbyte-config/init/src/main/resources/seed/source_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10694,7 +10694,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-sentry:0.1.1"
- dockerImage: "airbyte/source-sentry:0.1.2"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/sentry"
connectionSpecification:
Expand All @@ -10705,7 +10705,7 @@
- "auth_token"
- "organization"
- "project"
additionalProperties: false
additionalProperties: true
properties:
auth_token:
type: "string"
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-sentry/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_sentry ./source_sentry
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.version=0.1.2
LABEL io.airbyte.name=airbyte/source-sentry
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-sentry/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from setuptools import find_packages, setup

MAIN_REQUIREMENTS = [
"airbyte-cdk",
"airbyte-cdk~=0.1.74",
]

TEST_REQUIREMENTS = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
definitions:
page_size: 50
schema_loader:
type: JsonSchema
file_path: "./source_sentry/schemas/{{ options.name }}.json"
selector:
type: RecordSelector
extractor:
type: DpathExtractor
field_pointer: []
requester:
type: HttpRequester
name: "{{ options['name'] }}"
url_base: "https://{{ config.hostname }}/api/0/"
http_method: "GET"
authenticator:
type: "BearerAuthenticator"
api_token: "{{ config.auth_token }}"
paginator:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the test account doesn't have enough data to test the pagination...

Copy link
Contributor

Choose a reason for hiding this comment

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

what about our actual sentry account?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I was able to test the pagination on the events stream. The same pagination is used for issues and projects.

project_details does not have pagination https://docs.sentry.io/api/projects/retrieve-a-project/

type: LimitPaginator
url_base: "*ref(definitions.requester.url_base)"
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we passing url_base to the paginator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a bit of an implementation detail, but it's to replace the base url from the cursor when updating the path. although maybe that could be done in the retriever. left a comment on this

page_size: "*ref(definitions.page_size)"
limit_option:
inject_into: "request_parameter"
field_name: ""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a bit absurd to to need this... cursor pagination should be a first-class paginator

Copy link
Contributor

Choose a reason for hiding this comment

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

what does it mean to have an empty field_name? is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the right solution here is probably for limit_option and page_token_option to be optional. left a comment

page_token_option:
inject_into: "request_parameter"
field_name: "cursor"
pagination_strategy:
type: "CursorPagination"
cursor_value: "{{ headers.link.next.cursor }}"
stop_condition: "{{ headers.link.next.results != 'true' }}"
retriever:
type: SimpleRetriever
name: "{{ options['name'] }}"
primary_key: "{{ options['primary_key'] }}"

streams:
- type: DeclarativeStream
$options:
# https://docs.sentry.io/api/events/list-a-projects-events/
name: "events"
girarda marked this conversation as resolved.
Show resolved Hide resolved
primary_key: "id"
schema_loader:
$ref: "*ref(definitions.schema_loader)"
retriever:
$ref: "*ref(definitions.retriever)"
record_selector:
$ref: "*ref(definitions.selector)"
requester:
$ref: "*ref(definitions.requester)"
path: "projects/{{config.organization}}/{{config.project}}/events/"
request_options_provider:
request_parameters:
full: "true"
paginator:
$ref: "*ref(definitions.paginator)"
- type: DeclarativeStream
$options:
name: "issues"
primary_key: "id"
schema_loader:
$ref: "*ref(definitions.schema_loader)"
retriever:
$ref: "*ref(definitions.retriever)"
record_selector:
$ref: "*ref(definitions.selector)"
requester:
$ref: "*ref(definitions.requester)"
path: "projects/{{config.organization}}/{{config.project}}/issues/"
request_options_provider:
request_parameters:
statsPeriod: ""
query: ""
paginator:
$ref: "*ref(definitions.paginator)"
- type: DeclarativeStream
$options:
name: "projects"
primary_key: "id"
schema_loader:
$ref: "*ref(definitions.schema_loader)"
retriever:
$ref: "*ref(definitions.retriever)"
record_selector:
$ref: "*ref(definitions.selector)"
requester:
$ref: "*ref(definitions.requester)"
path: "projects/"
paginator:
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems incorrect? https://docs.sentry.io/api/projects/list-your-projects/ has paginatino

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. also added it to the issues stream

$ref: "*ref(definitions.paginator)"
- type: DeclarativeStream
$options:
name: "project_detail"
primary_key: "id"
schema_loader:
$ref: "*ref(definitions.schema_loader)"
retriever:
$ref: "*ref(definitions.retriever)"
record_selector:
$ref: "*ref(definitions.selector)"
requester:
$ref: "*ref(definitions.requester)"
path: "projects/{{config.organization}}/{{config.project}}/"
paginator:
type: NoPagination
check:
type: CheckStream
stream_names: ["project_detail"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,16 @@
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

from airbyte_cdk.sources.declarative.yaml_declarative_source import YamlDeclarativeSource

from typing import Any, List, Mapping, Tuple
"""
This file provides the necessary constructs to interpret a provided declarative YAML configuration file into
source connector.
WARNING: Do not modify this file.
"""

from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources import AbstractSource
from airbyte_cdk.sources.streams import Stream
from airbyte_cdk.sources.streams.http.auth import TokenAuthenticator

from .streams import Events, Issues, ProjectDetail, Projects


# Source
class SourceSentry(AbstractSource):
def check_connection(self, logger, config) -> Tuple[bool, Any]:
try:
projects_stream = Projects(
authenticator=TokenAuthenticator(token=config["auth_token"]),
hostname=config.get("hostname"),
)
next(projects_stream.read_records(sync_mode=SyncMode.full_refresh))
return True, None
except Exception as e:
return False, e

def streams(self, config: Mapping[str, Any]) -> List[Stream]:
stream_args = {
"authenticator": TokenAuthenticator(token=config["auth_token"]),
"hostname": config.get("hostname"),
}
project_stream_args = {
**stream_args,
"organization": config["organization"],
"project": config["project"],
}
return [
Events(**project_stream_args),
Issues(**project_stream_args),
ProjectDetail(**project_stream_args),
Projects(**stream_args),
]
# Declarative Source
class SourceSentry(YamlDeclarativeSource):
def __init__(self):
super().__init__(**{"path_to_yaml": "./source_sentry/sentry.yaml"})
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"title": "Sentry Spec",
"type": "object",
"required": ["auth_token", "organization", "project"],
"additionalProperties": false,
"additionalProperties": true,
"properties": {
"auth_token": {
"type": "string",
Expand Down
158 changes: 0 additions & 158 deletions airbyte-integrations/connectors/source-sentry/source_sentry/streams.py

This file was deleted.

Loading